package com.example.homework8.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MySQLHelper extends SQLiteOpenHelper {

    private static final String DB_NAME = "notepad.db";

    public static final int VERSION = 1;

    public static final String TABLE_USER = "CREATE TABLE user(" +
            "_id integer PRIMARY KEY," +
            "username TEXT NOT NULL," +
            "password TEXT NOT NULL," +
            "name TEXT NOT NULL," +
            "sex integer NOT NULL," +
            "birthday TEXT NOT NULL," +
            "head TEXT NOT NULL" +
            ");";

    public static final String TABLE_DIARY = "CREATE TABLE diary(" +
            "_id integer PRIMARY KEY," +
            "title TEXT NOT NULL," +
            "content TEXT NOT NULL," +
            "remindTime TEXT NOT NULL," +
            "tag integer NOT NULL," +
            "state integer NOT NULL," +
            "time DATE NOT NULL," +
            "image TEXT NOT NULL" +
            ");";

    public static final String TABLE_TAG = "CREATE TABLE tag(" +
            "tag_id integer PRIMARY KEY," +
            "describe TEXT NOT NULL" +
            ");";

    public MySQLHelper(Context context) {
        super(context, DB_NAME, null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(TABLE_USER);
        db.execSQL(TABLE_DIARY);
        db.execSQL(TABLE_TAG);
        db.execSQL("insert into tag values (0,'基础日记')");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}
